import { useState } from 'react';
import { useRoutes } from 'react-router-dom';
import Confirm from './components/Confirm';
import MessageHint from './components/MessageHint';
import { routesConfig } from './router.config';
import { AppContext, useAppContext } from './store/index.context';

function App() {
  const routes = useRoutes(routesConfig);
  const appContextValue = useAppContext();

  return (
    <AppContext.Provider value={appContextValue}>
      {routes}
      {appContextValue.messageStore.showMessage && <MessageHint />}
      {appContextValue.messageStore.showConfirm && <Confirm />}
    </AppContext.Provider>
  );
}

export default App;
